home *** CD-ROM | disk | FTP | other *** search
- package hhapplet;
-
- import java.applet.Applet;
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.Label;
- import java.awt.LayoutManager;
- import java.awt.List;
- import java.awt.Panel;
- import java.awt.TextField;
- import java.net.MalformedURLException;
- import java.util.Vector;
-
- public class IndexPane extends Panel implements DialogDoneTarget {
- protected Applet m_applet;
- protected Vector m_vSecondaryEntries = new Vector();
- protected List m_list;
- protected List m_listHolder;
- protected IndexTree m_forapplelistHolder;
- protected IndexTree m_forapplelist;
- protected TextField m_tfEdit = new TextField();
- protected Button m_btnDisplay = new Button("Display");
- protected IndexSecondaryDialog m_dlgSecondary;
- protected int m_nSelectedIndex = -1;
- protected Panel m_pnlEditArea = new Panel();
- protected Label m_lblEditArea = new Label("Type in the keyword to find:");
- protected LayoutManager m_layEditArea = new BorderLayout(0, 0);
- protected boolean m_bIsIE4 = false;
- protected boolean m_bIsNSWin16 = false;
- protected boolean m_bIsNSWin32 = false;
- protected boolean m_bIsIE3 = false;
- protected boolean m_bMacOS = false;
- protected boolean m_bUseForAppleList = false;
- private LayoutManager m_layout;
- MyThread m_textChangedThread = null;
-
- public boolean gotFocus(Event var1, Object var2) {
- if (this.m_bUseForAppleList) {
- if (var1.target != this.m_tfEdit && var1.target != this.m_forapplelist && var1.target != this.m_btnDisplay) {
- this.m_tfEdit.requestFocus();
- }
- } else if (var1.target != this.m_tfEdit && var1.target != this.m_list && var1.target != this.m_btnDisplay) {
- this.m_tfEdit.requestFocus();
- }
-
- return true;
- }
-
- public void HideList() {
- if (this.m_bUseForAppleList) {
- ((Container)this).add("Center", this.m_forapplelistHolder);
- this.m_forapplelistHolder.show(true);
- this.m_forapplelist.show(false);
- } else {
- ((Container)this).add("Center", this.m_listHolder);
- this.m_listHolder.show(true);
- this.m_list.show(false);
- }
-
- ((Container)this).paintComponents(((Component)this).getGraphics());
- }
-
- public IndexTree getForAppleList() {
- return this.m_forapplelistHolder;
- }
-
- public void MoveSelectionDown() {
- }
-
- public void dialogDone() {
- this.m_dlgSecondary = null;
- }
-
- public IndexPane(Applet var1) {
- this.m_applet = var1;
-
- try {
- if (System.getProperty("os.name").startsWith("MacOS")) {
- this.m_bMacOS = true;
- }
-
- if (System.getProperty("java.vendor").startsWith("Netscape")) {
- if (System.getProperty("os.name").startsWith("16-bit Windows")) {
- this.m_bIsNSWin16 = true;
- } else if (System.getProperty("os.name").startsWith("Windows")) {
- if (System.getProperty("java.version").equalsIgnoreCase("1.02")) {
- this.m_bUseForAppleList = true;
- }
-
- this.m_bIsNSWin32 = true;
- } else if (System.getProperty("os.name").startsWith("Mac")) {
- this.m_bUseForAppleList = true;
- }
- } else if (System.getProperty("java.vendor").startsWith("Microsoft")) {
- if (System.getProperty("java.version").startsWith("1.1")) {
- this.m_bIsIE4 = true;
- } else {
- this.m_bIsIE3 = true;
- }
-
- if (System.getProperty("os.name").startsWith("Mac")) {
- this.m_bUseForAppleList = true;
- }
-
- if (System.getProperty("java.version").equalsIgnoreCase("1.1")) {
- this.m_bUseForAppleList = true;
- } else if (System.getProperty("java.version").equalsIgnoreCase("1.0.2")) {
- this.m_bUseForAppleList = true;
- }
- }
- } finally {
- ;
- }
-
- if (this.m_bUseForAppleList) {
- this.m_forapplelist = new IndexTree(this);
- this.m_forapplelistHolder = new IndexTree((IndexPane)null);
- this.m_forapplelistHolder.addItem("Loading Index Data...");
- } else {
- this.m_list = new List();
- this.m_listHolder = new List();
- this.m_listHolder.addItem("Loading Index Data...");
- this.m_listHolder.setBackground(Color.white);
- }
-
- this.m_pnlEditArea.setLayout(this.m_layEditArea);
- this.m_pnlEditArea.add("North", this.m_lblEditArea);
- this.m_pnlEditArea.add("Center", this.m_tfEdit);
- this.m_layout = new BorderLayout(2, 2);
- ((Container)this).setLayout(this.m_layout);
- if (!this.m_bUseForAppleList) {
- this.m_list.setBackground(Color.white);
- }
-
- int var2 = WebHelp.GetFontSize();
- if (!this.m_bUseForAppleList) {
- this.m_list.setFont(new Font(WebHelp.GetFontName(), 0, var2));
- }
-
- this.m_tfEdit.setFont(new Font(WebHelp.GetFontName(), 0, var2));
- this.m_btnDisplay.setFont(new Font(WebHelp.GetFontName(), 0, var2));
- if (this.m_bUseForAppleList) {
- ((Container)this).add("Center", this.m_forapplelistHolder);
- } else {
- ((Container)this).add("North", this.m_pnlEditArea);
- ((Container)this).add("Center", this.m_listHolder);
- ((Container)this).add("South", this.m_btnDisplay);
- }
-
- this.m_tfEdit.requestFocus();
- }
-
- public void add(String var1, Vector var2) {
- if (this.m_bUseForAppleList) {
- this.m_forapplelist.addItem(var1);
- } else {
- this.m_list.addItem(var1);
- }
-
- this.m_vSecondaryEntries.addElement(var2);
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- return super.mouseUp(var1, var2, var3);
- }
-
- public List getList() {
- return this.m_list;
- }
-
- public void MoveSelectionPageDown() {
- }
-
- public int FindBaseKeywordForAppleList(int var1, int var2) {
- while(var1 > 0 && var2 < 0 || var1 < this.m_forapplelist.countItems() - 1 && var2 > 0) {
- if (this.m_forapplelist.getItem(var1).charAt(0) != ' ') {
- return var1;
- }
-
- var1 += var2;
- }
-
- return var1;
- }
-
- public void ShowList() {
- if (this.m_bUseForAppleList) {
- this.m_forapplelistHolder.show(false);
- ((Container)this).add("North", this.m_pnlEditArea);
- ((Container)this).add("Center", this.m_forapplelist);
- ((Container)this).add("South", this.m_btnDisplay);
- this.m_forapplelist.show(true);
- } else {
- this.m_listHolder.show(false);
- ((Container)this).add("North", this.m_pnlEditArea);
- ((Container)this).add("Center", this.m_list);
- ((Container)this).add("South", this.m_btnDisplay);
- this.m_list.show(true);
- }
-
- ((Component)this).paintAll(((Component)this).getGraphics());
- ((Container)this).paintComponents(((Component)this).getGraphics());
- }
-
- public TextField getEditBox() {
- return this.m_tfEdit;
- }
-
- public boolean keyUp(Event var1, int var2) {
- if ((var1.target == this.m_forapplelist || var1.target == this.m_list) && System.getProperty("java.version").equals("1.1") && System.getProperty("java.vendor").startsWith("Microsoft") && var1.key == 10) {
- this.action(var1, var1.target);
- return true;
- } else {
- if (this.m_bIsNSWin16) {
- var2 &= 255;
- }
-
- boolean var3 = super.keyUp(var1, var2);
- if (var2 >= 32 && var2 <= 126 && var1.target == this.m_tfEdit) {
- try {
- this.textChanged();
- if (var1.target == this.m_tfEdit) {
- this.m_tfEdit.requestFocus();
- }
- } finally {
- ;
- }
- }
-
- return var3;
- }
- }
-
- public boolean GetUseForAppleListFlag() {
- return this.m_bUseForAppleList;
- }
-
- public void gotoSelectedIndex() {
- int var1 = -1;
- if (this.m_bUseForAppleList) {
- var1 = this.m_forapplelist.getSelectedIndex();
- } else {
- var1 = this.m_list.getSelectedIndex();
- }
-
- if (var1 != -1) {
- if (((Vector)this.m_vSecondaryEntries.elementAt(var1)).size() == 1) {
- IndexSecondaryEntry var2 = (IndexSecondaryEntry)((Vector)this.m_vSecondaryEntries.elementAt(var1)).elementAt(0);
- if (var2.see_also != null) {
- for(int var3 = 0; var3 < this.m_vSecondaryEntries.size(); ++var3) {
- if (((Vector)this.m_vSecondaryEntries.elementAt(var3)).size() == 1) {
- IndexSecondaryEntry var4 = (IndexSecondaryEntry)((Vector)this.m_vSecondaryEntries.elementAt(var3)).elementAt(0);
- if (var4.name.equals(var2.see_also)) {
- if (this.m_bUseForAppleList) {
- this.m_forapplelist.select(var3);
- if (var3 > 0) {
- this.m_forapplelist.setTopIndex(var3 - 1);
- } else {
- this.m_forapplelist.setTopIndex(var3);
- }
-
- this.gotoSelectedIndex();
- return;
- }
-
- if (this.m_list.getVisibleIndex() != var3) {
- this.m_list.makeVisible(this.m_forapplelist.countItems() - 1);
- if (var3 > 0) {
- this.m_list.makeVisible(var3 - 1);
- } else {
- this.m_list.makeVisible(var3);
- }
- }
-
- this.m_list.select(var3);
- this.gotoSelectedIndex();
- return;
- }
- }
- }
-
- } else {
- try {
- if (var2.frame != null) {
- this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url), var2.frame);
- } else {
- this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url), "_self");
- }
- } catch (MalformedURLException var5) {
- }
- }
- } else {
- if (this.m_dlgSecondary != null) {
- this.m_dlgSecondary.closeDialog();
- this.m_dlgSecondary = null;
- }
-
- this.m_dlgSecondary = new IndexSecondaryDialog(this.m_applet, (Vector)this.m_vSecondaryEntries.elementAt(var1), this);
- this.m_dlgSecondary.show();
- this.m_dlgSecondary.getList().requestFocus();
- }
- }
- }
-
- public int FindBaseKeyword(int var1, int var2) {
- while(var1 > 0 && var2 < 0 || var1 < this.m_list.countItems() - 1 && var2 > 0) {
- if (this.m_list.getItem(var1).charAt(0) != ' ') {
- return var1;
- }
-
- var1 += var2;
- }
-
- return var1;
- }
-
- protected void finalize() throws Throwable {
- if (this.m_bUseForAppleList) {
- this.m_forapplelist.clear();
- this.m_forapplelist = null;
- } else {
- this.m_list.clear();
- this.m_list = null;
- }
-
- super.finalize();
- }
-
- public boolean action(Event var1, Object var2) {
- this.gotoSelectedIndex();
- return true;
- }
-
- public boolean handleEvent(Event var1) {
- if (System.getProperty("java.version").startsWith("1.1.5") && this.m_bIsNSWin32 && var1.id == 401 && var1.key == 10 && var1.target == this.m_btnDisplay) {
- this.action(var1, var1.target);
- return true;
- } else if (this.m_bIsIE4 && var1.id == 1001 && var1.target == this.m_tfEdit) {
- return true;
- } else {
- if (var1.target == this.m_list) {
- if (var1.id == 701 && this.m_list.getSelectedIndex() != this.m_nSelectedIndex) {
- String var2 = this.m_list.getSelectedItem();
- this.m_nSelectedIndex = this.m_list.getSelectedIndex();
- if (var2 != null) {
- this.m_tfEdit.setText(var2);
- this.m_applet.showStatus(var2);
- }
- }
- } else if (var1.target == this.m_tfEdit && var1.id == 403) {
- switch (var1.key) {
- case 1002:
- this.MoveSelectionPageUp();
- break;
- case 1003:
- this.MoveSelectionPageDown();
- break;
- case 1004:
- this.MoveSelectionUp();
- break;
- case 1005:
- this.MoveSelectionDown();
- }
- }
-
- return super.handleEvent(var1);
- }
- }
-
- public void textChanged() {
- if (this.m_textChangedThread == null) {
- this.m_textChangedThread = new MyThread(this);
- this.m_textChangedThread.setPriority(4);
- this.m_textChangedThread.start();
- } else {
- ++this.m_textChangedThread.m_bResearch;
- }
- }
-
- public void MoveSelectionUp() {
- }
-
- public void MoveSelectionPageUp() {
- }
-
- public boolean keyDown(Event var1, int var2) {
- if ((var1.target == this.m_forapplelist || var1.target == this.m_list) && (!System.getProperty("java.version").equals("1.1") || !System.getProperty("java.vendor").startsWith("Microsoft")) && var1.key == 10) {
- this.action(var1, var1.target);
- return true;
- } else {
- return super.keyDown(var1, var2);
- }
- }
- }
-